package com.lee.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by lee on 2017/3/14.
 */
public class JsonInterceptor implements HandlerInterceptor {

    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
        System.out.println("preHandle ");
        System.out.println(httpServletRequest.toString());
        System.out.println(httpServletResponse.toString());
        System.out.println(o.toString());

        return true;
    }

    public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
        System.out.println("postHandle");
        System.out.println(httpServletRequest.toString());
        System.out.println(httpServletResponse.toString());
        System.out.println(o.toString());
        // System.out.println(modelAndView.toString());
    }

    public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
        System.out.println("afterCompletion");
        System.out.println(httpServletRequest.getRequestURI() );

        // System.out.println(o.toString());
        System.out.println(e.toString());
    }
}
